/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cy.mybatis.genui;


import java.awt.Font;
import java.awt.Toolkit;
import java.net.URL;
import java.util.Enumeration;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;


/**
 *
 * @author cangyan
 */
public class MainApp {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try{
            //UIManager.setLookAndFeel( javax.swing.UIManager.getSystemLookAndFeelClassName());
            try{
                setfont("微软雅黑", 13);
            }catch(Exception e){
                try {
                    setfont("宋体", 13);
                } catch (Exception e2) {
                }
            }
            
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    MainFrame f = new MainFrame();
                    URL url =   f.getClass().getClassLoader().getResource("cy/res/mybatis.png");
                    f.setIconImage(Toolkit.getDefaultToolkit().getImage(url));
                    f.setVisible(true);
                }
            });
        } catch (Exception ex) {

        }
    }
    
    public static void setfont(String fontName, int size) throws Exception{
        Font font = new Font(fontName, Font.PLAIN, size);
        FontUIResource fontRes = new FontUIResource(font);
        for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource) {
                UIManager.put(key, fontRes);
            }
        }
    }

}
